package Tist1;

import java.util.Random;

public class Role {
    private String name;
    private int bool;
    private int power;
    private char gender;
    private String face;

    String[] boyface = {"英俊潇洒", "风流倜傥", "相貌平平", "奇丑无比", "面目狰狞"};
    String[] girlface = {"美轮美奂", "沉鱼落雁", "亭亭玉立", "小家碧玉", "相貌简陋", "令人生厌",};

    public Role() {
    }

    public Role(String name, int bool, int power, char gender) {
        this.name = name;
        this.bool = bool;
        this.power = power;
        this.gender = gender;
        setFace(gender);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getBool() {
        return bool;
    }

    public void setBool(int bool) {
        this.bool = bool;
    }

    public int getPower() {
        return power;
    }

    public void setPower(int power) {
        this.power = power;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public String getFace() {
        return face;
    }

    public void setFace(char gender) {
        Random r = new Random();
        if (gender == '男') {
            int index = r.nextInt(boyface.length);
            this.face = boyface[index];
        } else if (gender == '女') {
            int index = r.nextInt(girlface.length);
            this.face = girlface[index];
        } else {
            this.face = "不知面容";
        }

    }

    //定义一个方法用于攻击别人
    public void attack(Role role) {
        //伤害
        Random r = new Random();
        int hurt = r.nextInt(this.getPower());
        //剩余血量
        int remainBlood = role.getBool() - hurt;
        remainBlood = remainBlood < 0 ? 0 : remainBlood;
        role.setBool(remainBlood);
        System.out.println(this.getName() + "攻击" + role.getName() + "造成了" + hurt + "伤害");
        System.out.println(role.getName() + "还剩" + remainBlood + "血量");
    }

    public void show() {
        System.out.println(getName());
        System.out.println(getBool());
        System.out.println(getPower());
        System.out.println(getGender());
        System.out.println(getFace());
    }
}
